package com.OnTimeTeam.OnTime;

import java.util.ArrayList;
import java.util.Calendar;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class ListsManagerAdapter  extends ArrayAdapter<Boolean> {

	private ArrayList<String> labels; //all alarms details
	private ArrayList<Boolean> fixedArray;
	
	///////////////
	//CTOR - init' the array of AlarmFeatures and ApplicationContext object
	public ListsManagerAdapter(Context context, int textViewResourceId, ArrayList<String> labels, ArrayList<Boolean> fixedArray) {
		super(context, textViewResourceId, fixedArray);
		this.labels = labels;
		this.fixedArray = fixedArray;
	}

	////////////////////
	//This method sets the view of ONE item in the list (it gets it's index - it's the same index as the AlarmFeatures ArrayList)
	public View getView(final int index, View convertView, ViewGroup parent) {
	
		View view = convertView;
		LayoutInflater inflater = null;
		
		if (view == null) {
			inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.day_item, null);//set the view
		}
		
		TextView day = (TextView)view.findViewById(R.id.dayRep);
		CheckBox check = (CheckBox)view.findViewById(R.id.check); 
		check.setFocusable(false);
		check.setClickable(false);
		check.setChecked(false);


		day.setText(labels.get(index));

		if(fixedArray.get(index))
			check.setChecked(true);
		
		//return the view of the item
		return view;
	
	}//end of method 'getView'
	
}//EOF
